from PIL import Image
from yolo import YOLO

if __name__ == "__main__":
    yolo = YOLO()
    while True:
        img = input('请输入待检测的图片路径（输入"q"结束检测）:')
        if img == 'q':
            break
        try:
            image = Image.open(img)
        except:
            print('无法打开图片，请确认图片路径。')
            continue
        else:
            r_image = yolo.detect_image(image)
            r_image.show()
